<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ page import="com.gouwudai.gobbs.pojo.TbbsClass" %>
<%@ include file="../../common/common.jsp" %>
<%@ include file="master_pass.jsp" %>
<% 
Integer classId = Utility.parseInt(request.getParameter("classId"));

IClassService classService = (IClassService)BeanManager.getBean("classService");
TbbsClass obj = classService.load(classId);
%>
<HTML>
<HEAD>
<title>编辑分类/版面</title>
<%@ include file="../../common/meta.inc" %>
<link href="css.css" rel="stylesheet" type="text/css">
<base target="_self">
<SCRIPT LANGUAGE="javascript" SRC="${pageContext.request.contextPath}/scripts/common-validator.js"></SCRIPT>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
<script language="javascript">
var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);
function doSubmit() {

	form = document.theform;
	
	if(!validateForm(form))
		return;
		
    var obj = {};
	obj[Buffalo.BOCLASS] = "com.gouwudai.gobbs.pojo.TbbsClass";
	obj.classId=<%=classId%>;	
	
	obj.className=$F('className');	
	obj.classLevel=0;	//暂时不处理
	obj.orders=parseInt($F('orders'));
	obj.parentId=parseInt($F('parentId'));
	obj.classType=parseInt(getRadioValue('classType'));
	obj.classStyle=parseInt(getRadioValue('classStyle'));
	obj.hiddenFlag=sl_parseBoolean(getRadioValue('hiddenFlag'));
	obj.childOpenFlag=sl_parseBoolean(getRadioValue('childOpenFlag'));
	obj.classPro=parseInt($F('classPro'));
	obj.accessGrade=parseInt($F('accessGrade'));
	obj.topicDisNum=parseInt($F('topicDisNum'));
	obj.replyDisNum=parseInt($F('replyDisNum'));
	obj.mostOnline=parseInt($F('mostOnline'));
	obj.summary=$F('summary');		
	obj.upfileMaxSize=parseInt($F('upfileMaxSize'));
	obj.upfileOpenFlag=sl_parseBoolean(getRadioValue('upfileOpenFlag'));
	var rebuildIndex = $('rebuildIndex');
	var rebuildIndexFlag = false;
	if(rebuildIndex.checked)
		rebuildIndexFlag = true;	
	else
		rebuildIndexFlag = false;		
    buffalo.remoteCall("classServiceAjaxService.update",[obj,rebuildIndexFlag], function(reply) {
        ajaxSubmit(reply.getResult(),"保存成功！","back");
    });
}

function validateForm(form)
{
   	if(!sl_check(form.className,"名称",50,1)) return false; 	
   	if(!sl_checkIntValue(form.orders,"排序ID",1000,0)) return false;
  	if(!sl_checkIntValue(form.topicDisNum,"每页显示主题数",100,1)) return false;
    if(!sl_checkIntValue(form.replyDisNum,"每篇主题每页显示回复数",200,1)) return false;
    if(!sl_checkIntValue(form.mostOnline,"最高允许在线人数",9999,0)) return false;    
    if(!sl_checkIntValue(form.upfileMaxSize,"单个文件最大限制",5000,0)) return false;     
    return sl_confirmUpdate();
}
</script>
</HEAD>
<body>
<form name="theform" method="post" action="">
<table width="99%" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#e6e6e6">
  <tr>
    <td align="center" colspan="2"><strong>编辑社区分类/版面</strong></td>
  </tr>
 <tr bgcolor="#f6f6f6">
    <td width="116" bgcolor="#f6f6f6"><strong>名称</strong></td>
	<td><input type="text" name="className" id="className" value="<%=obj.getClassName() %>" size="20"></td>
  </tr>
  <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>排序ID</strong></td>
      <td><input type="text" name="orders" id="orders"  value="<%=Utility.trimNull(obj.getOrders()) %>"  size="4"  maxlength="4">       
        <span class="remark">请填写整数数字，越大排位越靠前。</span></td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>所属分类</strong></td>
      <td>
		<select name="parentId" id="parentId">
			<option value="0">&lt;顶层分类&gt;</option>
			<%=Arguments.getClassOptions(obj.getParentId())%>
		</select>
		<span class="remark">(只有在分类下才能建设分版)</span>
	  </td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>类别</strong></td>
      <td>
		<input type="radio" name="classType" id="classType" value="0" <%=Arguments.getRadioStatus(obj.getClassType().toString(),"0") %>/>作为分类
		&nbsp;&nbsp;
		<input type="radio" name="classType" id="classType" value="1" <%=Arguments.getRadioStatus(obj.getClassType().toString(),"1") %> <%if(obj.getClassType().shortValue()==0) {out.print("disabled");} %>/>作为版面
	  </td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>默认的打开风格</strong></td>
      <td>
		<input type="radio" name="classStyle" id="classStyle" value="0" <%=Arguments.getRadioStatus(obj.getClassStyle().toString(),"0") %>/>论坛风格
		&nbsp;&nbsp;
		<input type="radio" name="classStyle" id="classStyle" value="1" <%=Arguments.getRadioStatus(obj.getClassStyle().toString(),"1") %>/>讨论区风格

	  </td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>是否隐藏</strong></td>
      <td>
		<input type="radio" name="hiddenFlag" id="hiddenFlag" value="false" <%=Arguments.getRadioStatus(obj.getHiddenFlag(),false) %>/>不隐藏
		&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="radio" name="hiddenFlag" id="hiddenFlag" value="true" <%=Arguments.getRadioStatus(obj.getHiddenFlag(),true) %>/>隐藏
		&nbsp;&nbsp;<span class="remark">（隐藏的版面或分类不影响访问）</span> </td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>下属版面是否打开</strong></td>
      <td>
		<input type="radio" name="childOpenFlag" id="childOpenFlag" value="false"  <%=Arguments.getRadioStatus(obj.getChildOpenFlag(),false) %>/>不打开
		&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="radio" name="childOpenFlag" id="childOpenFlag" value="true"  <%=Arguments.getRadioStatus(obj.getChildOpenFlag(),true) %>/>打开
		&nbsp;&nbsp;<span class="remark">（隐藏的版面或分类不影响访问）</span></td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>属性</strong></td>
      <td><select name="classPro" id="classPro">
        <%=Arguments.getDictParamOptionsNo("S007",obj.getClassPro()) %>
      </select>&nbsp;&nbsp;
      <span class="remark">链接的属性请在简介处输入URL地址</span></td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>浏览等级</strong></td>
      <td>
		<select id="accessGrade" name="accessGrade">
		<%=Arguments.getUserGradeOptions(obj.getAccessGrade())%>
		</select>
	  </td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>参数设定</strong></td>
      <td>
［1］每页显示主题<input type="text" name="topicDisNum" id="ccTopicNum" value="<%=obj.getTopicDisNum() %>" size="4" maxlength="4">篇
<br/>
［2］每篇主题每页显示回复<input type="text" name="replyDisNum" id="replyDisNum" value="<%=obj.getReplyDisNum() %>"  size="4" maxlength="4">篇
<br/>
［3］最高允许在线<input type="text"  name="mostOnline"  id="mostOnline" value="<%=obj.getMostOnline() %>" size="5" maxlength="5">人<span class="remark">（0为不限制）</span></td>
</tr>
<tr bgcolor="#f6f6f6">
<td bgcolor="#f6f6f6"><strong>简介</strong></td>
<td>
<textarea name="summary" cols="50" rows="6" id="summary"><%=Utility.trimNull(obj.getSummary()) %></textarea>
</td>
</tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFCC">
      <td colspan="2"><strong>以下参数仅对社区版面有效，对分类无效！</strong></td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>附件上传</strong></td>
      <td>
			<input type="radio" name="upfileOpenFlag" id="upfileOpenFlag" value="true"  <%=Arguments.getRadioStatus(obj.getUpfileOpenFlag(),true) %>/>默认打开
			<input type="radio" name="upfileOpenFlag" id="upfileOpenFlag" value="false"  <%=Arguments.getRadioStatus(obj.getUpfileOpenFlag(),false) %>/>关闭 
	  </td>
    </tr>
    <tr bgcolor="#f6f6f6">
      <td bgcolor="#f6f6f6"><strong>单个文件最大限制</strong></td>
      <td>
		<input type="text" name="upfileMaxSize" id="upfileMaxSize" value="<%=obj.getUpfileMaxSize() %>" size="10" maxlength="10">
		单位Bytes<span class="remark">(0为不限制)</span>
	  </td>
    </tr>
  </table>  
 <table border="0" width="100%">
	<tr>
		<td align="right">
		<button class="btn" accessKey=s id="btnSave" name="btnSave" onclick="javascript:doSubmit();">保存(<u>S</u>)</button>
		&nbsp;&nbsp;
		<button class="btn" accessKey=r id="btnCancel" name="btnCancel" onclick="javascript:history.back()">返回(<u>R</u>)</button>
		&nbsp;&nbsp;
		<input type="checkbox" checked name="rebuildIndex" id="rebuildIndex" value="1">同时更新前台导航按钮								
		</td>
	</tr>	
 </table>	
 </form>
</body>
</html>
